
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Git基础 · AGou's StudyNote</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="AGou">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-tomorrow.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-lightbox/css/lightbox.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="GitLab服务器.html" />
    
    
    <link rel="prev" href="./" />
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"repo":"AGou-ops/myStudyNote","types":["star","watch","fork"],"size":"small"};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://agou-ops.github.io" target="_blank" class="custom-link">◆点击进入我的个人博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                        <b>1.1.</b>
                    
                    关于我
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Program_lang/">
            
                <a href="../Program_lang/">
            
                    
                        <b>1.2.</b>
                    
                    编程语言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Program_lang/Python.html">
            
                <a href="../Program_lang/Python.html">
            
                    
                        <b>1.2.1.</b>
                    
                    Python
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../Program_lang/Java.html">
            
                <a href="../Program_lang/Java.html">
            
                    
                        <b>1.2.2.</b>
                    
                    Java
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../Program_lang/Splash_Lua.html">
            
                <a href="../Program_lang/Splash_Lua.html">
            
                    
                        <b>1.2.3.</b>
                    
                    Splash_Lua
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../Database/">
            
                <a href="../Database/">
            
                    
                        <b>1.3.</b>
                    
                    数据库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../Database/Mysql、MariaDB/README.md">
            
                <span>
            
                    
                        <b>1.3.1.</b>
                    
                    Mysql/MariaDB
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1.1" data-path="../Database/Mysql、MariaDB/MySQL、MariaDB基础.html">
            
                <a href="../Database/Mysql、MariaDB/MySQL、MariaDB基础.html">
            
                    
                        <b>1.3.1.1.</b>
                    
                    MySQL/MariaDB基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.2" data-path="../Database/Mysql、MariaDB/php-mysql.html">
            
                <a href="../Database/Mysql、MariaDB/php-mysql.html">
            
                    
                        <b>1.3.1.2.</b>
                    
                    php-mysql
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../Database/MongoDB.html">
            
                <a href="../Database/MongoDB.html">
            
                    
                        <b>1.3.2.</b>
                    
                    MongoDB
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../Database/Redis.html">
            
                <a href="../Database/Redis.html">
            
                    
                        <b>1.3.3.</b>
                    
                    Redis
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../Linux/">
            
                <a href="../Linux/">
            
                    
                        <b>1.4.</b>
                    
                    Linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../Linux/Linux基础.html">
            
                <a href="../Linux/Linux基础.html">
            
                    
                        <b>1.4.1.</b>
                    
                    Linux基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../Linux/Linux启动流程、内核、grub、模块、内核的编译、anaconda自动化.html">
            
                <a href="../Linux/Linux启动流程、内核、grub、模块、内核的编译、anaconda自动化.html">
            
                    
                        <b>1.4.2.</b>
                    
                    Linux启动流程、内核、grub、模块等
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../Linux/Linux服务器.html">
            
                <a href="../Linux/Linux服务器.html">
            
                    
                        <b>1.4.3.</b>
                    
                    Linux服务器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../Linux/Linux状态信息.html">
            
                <a href="../Linux/Linux状态信息.html">
            
                    
                        <b>1.4.4.</b>
                    
                    Linux状态信息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../Linux/Linux网络客户端工具.html">
            
                <a href="../Linux/Linux网络客户端工具.html">
            
                    
                        <b>1.4.5.</b>
                    
                    Linux网络客户端工具
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../Linux/Linux网络配置.html">
            
                <a href="../Linux/Linux网络配置.html">
            
                    
                        <b>1.4.6.</b>
                    
                    Linux网络配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../Linux/Linux配置文件.md">
            
                <span>
            
                    
                        <b>1.4.7.</b>
                    
                    Linux配置文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../Linux/Linux时间服务器.html">
            
                <a href="../Linux/Linux时间服务器.html">
            
                    
                        <b>1.4.8.</b>
                    
                    Linux时间服务器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../Linux/Linux日志管理系统.html">
            
                <a href="../Linux/Linux日志管理系统.html">
            
                    
                        <b>1.4.9.</b>
                    
                    Linux日志管理系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../Linux/sudo详解.html">
            
                <a href="../Linux/sudo详解.html">
            
                    
                        <b>1.4.10.</b>
                    
                    sudo详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.11" data-path="../Linux/SElinux.html">
            
                <a href="../Linux/SElinux.html">
            
                    
                        <b>1.4.11.</b>
                    
                    SELinux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.12" data-path="../Linux/iptables.html">
            
                <a href="../Linux/iptables.html">
            
                    
                        <b>1.4.12.</b>
                    
                    iptables
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.13" data-path="../Linux/Linux_shell.html">
            
                <a href="../Linux/Linux_shell.html">
            
                    
                        <b>1.4.13.</b>
                    
                    Linux Shell
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.14" data-path="../Linux/shell_awk.html">
            
                <a href="../Linux/shell_awk.html">
            
                    
                        <b>1.4.14.</b>
                    
                    shell_awk
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.15" data-path="../Linux/OpenSSL、PKI搭建、算法.html">
            
                <a href="../Linux/OpenSSL、PKI搭建、算法.html">
            
                    
                        <b>1.4.15.</b>
                    
                    OpenSSL、PKI搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.16" data-path="../Linux/DNS服务器.html">
            
                <a href="../Linux/DNS服务器.html">
            
                    
                        <b>1.4.16.</b>
                    
                    DNS服务器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.17" data-path="../Linux/Frp内网穿透.html">
            
                <a href="../Linux/Frp内网穿透.html">
            
                    
                        <b>1.4.17.</b>
                    
                    Frp内网穿透
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.18" data-path="../Linux/Linux其他.md">
            
                <span>
            
                    
                        <b>1.4.18.</b>
                    
                    Linux其他
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../Linux_FileSystem/">
            
                <a href="../Linux_FileSystem/">
            
                    
                        <b>1.5.</b>
                    
                    Linux文件系统
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Linux_FileSystem/FTP.html">
            
                <a href="../Linux_FileSystem/FTP.html">
            
                    
                        <b>1.5.1.</b>
                    
                    FTP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../Linux_FileSystem/SAMBA.html">
            
                <a href="../Linux_FileSystem/SAMBA.html">
            
                    
                        <b>1.5.2.</b>
                    
                    SAMBA
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../Linux_Tools/">
            
                <a href="../Linux_Tools/">
            
                    
                        <b>1.6.</b>
                    
                    Linux工具
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../Linux_Tools/fzf工具.html">
            
                <a href="../Linux_Tools/fzf工具.html">
            
                    
                        <b>1.6.1.</b>
                    
                    fzf工具
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../Linux_Tools/工具集合.html">
            
                <a href="../Linux_Tools/工具集合.html">
            
                    
                        <b>1.6.2.</b>
                    
                    Linux工具集合
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../WEB_Server/">
            
                <a href="../WEB_Server/">
            
                    
                        <b>1.7.</b>
                    
                    网站服务器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../WEB_Server/HTML基础.html">
            
                <a href="../WEB_Server/HTML基础.html">
            
                    
                        <b>1.7.1.</b>
                    
                    HTML基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../WEB_Server/WEB基础.html">
            
                <a href="../WEB_Server/WEB基础.html">
            
                    
                        <b>1.7.2.</b>
                    
                    WEB基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../WEB_Server/httpd.html">
            
                <a href="../WEB_Server/httpd.html">
            
                    
                        <b>1.7.3.</b>
                    
                    httpd/Apache
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../WEB_Server/httpd.conf文件详解.html">
            
                <a href="../WEB_Server/httpd.conf文件详解.html">
            
                    
                        <b>1.7.4.</b>
                    
                    httpd.conf文件详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../WEB_Server/Nginx.html">
            
                <a href="../WEB_Server/Nginx.html">
            
                    
                        <b>1.7.5.</b>
                    
                    Nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../WEB_Server/HTTP状态码-详情.html">
            
                <a href="../WEB_Server/HTTP状态码-详情.html">
            
                    
                        <b>1.7.6.</b>
                    
                    HTTP状态码-详情
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../Common_Framework/">
            
                <a href="../Common_Framework/">
            
                    
                        <b>1.8.</b>
                    
                    常用框架
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../Common_Framework/LNMP.html">
            
                <a href="../Common_Framework/LNMP.html">
            
                    
                        <b>1.8.1.</b>
                    
                    LNMP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../Common_Framework/LAMP.html">
            
                <a href="../Common_Framework/LAMP.html">
            
                    
                        <b>1.8.2.</b>
                    
                    LAMP
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../Docker&K8s/">
            
                <a href="../Docker&K8s/">
            
                    
                        <b>1.9.</b>
                    
                    容器及容器编排
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../Docker&K8s/Docker/Docker.html">
            
                <a href="../Docker&K8s/Docker/Docker.html">
            
                    
                        <b>1.9.1.</b>
                    
                    Docker
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1.1" data-path="../Docker&K8s/Docker/Docker.html">
            
                <a href="../Docker&K8s/Docker/Docker.html">
            
                    
                        <b>1.9.1.1.</b>
                    
                    Docker
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../Docker&K8s/K8s/">
            
                <a href="../Docker&K8s/K8s/">
            
                    
                        <b>1.9.2.</b>
                    
                    K8s
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.2.1" data-path="../Docker&K8s/K8s/K8s基础知识.html">
            
                <a href="../Docker&K8s/K8s/K8s基础知识.html">
            
                    
                        <b>1.9.2.1.</b>
                    
                    K8s基础知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2.2" data-path="../Docker&K8s/K8s/K8s安装与部署.html">
            
                <a href="../Docker&K8s/K8s/K8s安装与部署.html">
            
                    
                        <b>1.9.2.2.</b>
                    
                    K8s安装与部署
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="./">
            
                <a href="./">
            
                    
                        <b>1.10.</b>
                    
                    Git
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.10.1" data-path="Git基础.html">
            
                <a href="Git基础.html">
            
                    
                        <b>1.10.1.</b>
                    
                    Git基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="GitLab服务器.html">
            
                <a href="GitLab服务器.html">
            
                    
                        <b>1.10.2.</b>
                    
                    GitLab服务器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../Windows/">
            
                <a href="../Windows/">
            
                    
                        <b>1.11.</b>
                    
                    Windows系统
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../Windows/cmd命令.html">
            
                <a href="../Windows/cmd命令.html">
            
                    
                        <b>1.11.1.</b>
                    
                    cmd命令
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../Vim.html">
            
                <a href="../Vim.html">
            
                    
                        <b>1.12.</b>
                    
                    Vim
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../i3WM快捷键.html">
            
                <a href="../i3WM快捷键.html">
            
                    
                        <b>1.13.</b>
                    
                    i3WM快捷键
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../ADB命令.html">
            
                <a href="../ADB命令.html">
            
                    
                        <b>1.14.</b>
                    
                    ADB命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../Tmux.html">
            
                <a href="../Tmux.html">
            
                    
                        <b>1.15.</b>
                    
                    Tmux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../Kindle.html">
            
                <a href="../Kindle.html">
            
                    
                        <b>1.16.</b>
                    
                    Kindle越狱指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../Other/">
            
                <a href="../Other/">
            
                    
                        <b>1.17.</b>
                    
                    Other
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../Other/pandoc.html">
            
                <a href="../Other/pandoc.html">
            
                    
                        <b>1.17.1.</b>
                    
                    pandoc
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../Other/jupyter&reveal.js.html">
            
                <a href="../Other/jupyter&reveal.js.html">
            
                    
                        <b>1.17.2.</b>
                    
                    jupyter & reveal.js
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../Other/json.html">
            
                <a href="../Other/json.html">
            
                    
                        <b>1.17.3.</b>
                    
                    json
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../Other/Reveal_js.html">
            
                <a href="../Other/Reveal_js.html">
            
                    
                        <b>1.17.4.</b>
                    
                    Reveal_js
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Git基础</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-anchor"></i><ul><li><a href="#&#x57FA;&#x7840;&#x8BBE;&#x7F6E;">1. &#x57FA;&#x7840;&#x8BBE;&#x7F6E;</a></li><li><a href="#git&#x7248;&#x672C;&#x7BA1;&#x7406;">2. Git&#x7248;&#x672C;&#x7BA1;&#x7406;</a></li><ul><li><a href="#&#x7248;&#x672C;&#x56DE;&#x9000;">2.1. &#x7248;&#x672C;&#x56DE;&#x9000;</a></li><ul><li><a href="#git-reset">2.1.1. git reset</a></li><li><a href="#git-revert">2.1.2. git revert</a></li></ul><li><a href="#&#x7BA1;&#x7406;&#x4FEE;&#x6539;">2.2. &#x7BA1;&#x7406;&#x4FEE;&#x6539;</a></li></ul><li><a href="#git&#x5206;&#x652F;&#x7BA1;&#x7406;">3. Git&#x5206;&#x652F;&#x7BA1;&#x7406;</a></li><ul><li><a href="#&#x521B;&#x5EFA;&#x67E5;&#x770B;&#x5207;&#x6362;&#x5408;&#x5E76;&#x5220;&#x9664;&#x5206;&#x652F;">3.1. &#x521B;&#x5EFA;&#x67E5;&#x770B;&#x5207;&#x6362;&#x5408;&#x5E76;&#x5220;&#x9664;&#x5206;&#x652F;</a></li><li><a href="#&#x5206;&#x652F;&#x7BA1;&#x7406;&#x7B56;&#x7565;">3.2. &#x5206;&#x652F;&#x7BA1;&#x7406;&#x7B56;&#x7565;</a></li><li><a href="#bug&#x5206;&#x652F;">3.3. BUG&#x5206;&#x652F;</a></li><li><a href="#git-rebase">3.4. Git Rebase</a></li><li><a href="#&#x8FDC;&#x7A0B;&#x5206;&#x652F;&#x7BA1;&#x7406;">3.5. &#x8FDC;&#x7A0B;&#x5206;&#x652F;&#x7BA1;&#x7406;</a></li></ul><li><a href="#git&#x6807;&#x7B7E;&#x7BA1;&#x7406;">4. Git&#x6807;&#x7B7E;&#x7BA1;&#x7406;</a></li><ul><li><a href="#&#x521B;&#x5EFA;&#x6807;&#x7B7E;">4.1. &#x521B;&#x5EFA;&#x6807;&#x7B7E;</a></li><li><a href="#&#x5220;&#x9664;&#x672C;&#x5730;&#x6216;&#x8FDC;&#x7A0B;&#x6807;&#x7B7E;">4.2. &#x5220;&#x9664;&#x672C;&#x5730;&#x6216;&#x8FDC;&#x7A0B;&#x6807;&#x7B7E;</a></li></ul><li><a href="#gitignore&#x6587;&#x4EF6;">5. .gitignore&#x6587;&#x4EF6;</a></li><li><a href="#git&#x5176;&#x4ED6;">6. Git&#x5176;&#x4ED6;</a></li></ul></div><a href="#&#x57FA;&#x7840;&#x8BBE;&#x7F6E;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><blockquote>
<p><strong>This is Git&#x547D;&#x4EE4; StudyNote.</strong></p>
</blockquote>
<h1 id="&#x57FA;&#x7840;&#x8BBE;&#x7F6E;"><a name="&#x57FA;&#x7840;&#x8BBE;&#x7F6E;" class="anchor-navigation-ex-anchor" href="#&#x57FA;&#x7840;&#x8BBE;&#x7F6E;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x57FA;&#x7840;&#x8BBE;&#x7F6E;</h1>
<p><strong>&#x5168;&#x5C40;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF1A;<code>~/.gitconfig</code></strong></p>
<p>&#x8BBE;&#x7F6E;&#x5168;&#x5C40;&#x767B;&#x5F55;&#x4FE1;&#x606F;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> config --global user.name <span class="token string">&quot;YOURUSERNAME&quot;</span> 
<span class="token function">git</span> config --global user.email <span class="token string">&quot;YOUREMAIL&quot;</span>
</code></pre>
<p>&#x5982;&#x679C;&#x53EA;&#x60F3;&#x5BF9;&#x5F53;&#x524D;&#x9879;&#x76EE;&#x8BBE;&#x7F6E;&#x767B;&#x5F55;&#x4FE1;&#x606F;&#x7684;&#x8BDD;&#xFF0C;&#x53BB;&#x6389;<code>--global</code>&#x53C2;&#x6570;&#x5373;&#x53EF;</p>
<p>&#x8BBE;&#x7F6E;&#x65E0;&#x5BC6;&#x7801;SSH-KEY&#x767B;&#x5F55;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token comment"># &#x5728;&#x7528;&#x6237;&#x5BB6;&#x76EE;&#x5F55;&#x7684;.ssh&#x76EE;&#x5F55;&#x4E2D;&#x751F;&#x6210;id_rsa&#x548C;id_rsa.pub&#x8FD9;&#x4E24;&#x4E2A;&#x6587;&#x4EF6;</span>
ssh-keygen -t rsa -C <span class="token string">&quot;youremail@example.com&quot;</span>

* &#x63A5;&#x4E0B;&#x6765;&#x6253;&#x5F00;Github&#x7684;&#x76F8;&#x5173;&#x914D;&#x7F6E;&#x9875;&#x5BFC;&#x5165;<span class="token variable"><span class="token variable">`</span>id_rsa.pub<span class="token variable">`</span></span>&#x6587;&#x4EF6;&#x5185;&#x5BB9;

<span class="token comment"># &#x68C0;&#x67E5;&#x662F;&#x5426;&#x53EF;&#x7528;</span>
<span class="token function">ssh</span> -T git@github.com
</code></pre>
<p>&#x914D;&#x7F6E;&#x522B;&#x540D;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token comment"># &#x5C06;status&#x8D77;&#x4E2A;&#x522B;&#x540D;&#x4E3A;st&#xFF0C;&#x6B64;&#x65F6;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;git st&#x6765;&#x67E5;&#x770B;&#x5DE5;&#x4F5C;&#x533A;&#x72B6;&#x6001;&#x4E86;</span>
<span class="token function">git</span> config --global alias.st status
<span class="token function">git</span> config --global alias.lone <span class="token string">&apos;log --oneline&apos;</span>
</code></pre>
<h1 id="git&#x7248;&#x672C;&#x7BA1;&#x7406;"><a name="git&#x7248;&#x672C;&#x7BA1;&#x7406;" class="anchor-navigation-ex-anchor" href="#git&#x7248;&#x672C;&#x7BA1;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>2. Git&#x7248;&#x672C;&#x7BA1;&#x7406;</h1>
<h2 id="&#x7248;&#x672C;&#x56DE;&#x9000;"><a name="&#x7248;&#x672C;&#x56DE;&#x9000;" class="anchor-navigation-ex-anchor" href="#&#x7248;&#x672C;&#x56DE;&#x9000;"><i class="fa fa-link" aria-hidden="true"></i></a>2.1. &#x7248;&#x672C;&#x56DE;&#x9000;</h2>
<h3 id="git-reset"><a name="git-reset" class="anchor-navigation-ex-anchor" href="#git-reset"><i class="fa fa-link" aria-hidden="true"></i></a>2.1.1. git reset</h3>
<ol>
<li>&#x4F7F;&#x7528;<code>git log</code>&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x5F53;&#x524D;&#x63D0;&#x4EA4;&#x60C5;&#x51B5;&#xFF1A;</li>
</ol>
<pre class="language-"><code class="lang-bash">&#x279C;  <span class="token function">git</span> git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> log                                          
commit dadac050104f374d34d7257779ab958e86a578cb <span class="token punctuation">(</span>HEAD -<span class="token operator">&gt;</span> master<span class="token punctuation">)</span>
Author: AGou-ops <span class="token operator">&lt;</span>suofeiyaxx@gmail.com<span class="token operator">&gt;</span>
Date:   Wed Dec <span class="token number">4</span> <span class="token number">18</span>:45:58 <span class="token number">2019</span> +0800

    INIT <span class="token builtin class-name">test</span> <span class="token function">file</span> with <span class="token number">4</span><span class="token punctuation">..</span>

commit 5826c364bbbd7976bd7ab23e77256a8c44db37e6
Author: AGou-ops <span class="token operator">&lt;</span>suofeiyaxx@gmail.com<span class="token operator">&gt;</span>
Date:   Wed Dec <span class="token number">4</span> <span class="token number">18</span>:45:15 <span class="token number">2019</span> +0800

    INIT <span class="token builtin class-name">test</span> <span class="token function">file</span> with <span class="token number">1</span><span class="token punctuation">..</span><span class="token number">2</span><span class="token punctuation">..</span><span class="token number">3</span>
</code></pre>
<p>&#x5982;&#x679C;&#x89C9;&#x5F97;&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x592A;&#x4E71;&#x592A;&#x6742;&#x53EF;&#x4EE5;&#x52A0;&#x4E0A;<code>--pretty-oneline</code>&#x53C2;&#x6570;&#x6216;&#x8005;&#x77ED;<code>commit hash</code>&#x524D;&#x4E03;&#x4F4D;&#x7684;<code>--oneline</code>&#x53C2;&#x6570;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">&#x279C;  <span class="token function">git</span> git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> log --pretty<span class="token operator">=</span>oneline                          
dadac050104f374d34d7257779ab958e86a578cb <span class="token punctuation">(</span>HEAD -<span class="token operator">&gt;</span> master<span class="token punctuation">)</span> INIT <span class="token builtin class-name">test</span> <span class="token function">file</span> with <span class="token number">4</span><span class="token punctuation">..</span>
5826c364bbbd7976bd7ab23e77256a8c44db37e6 INIT <span class="token builtin class-name">test</span> <span class="token function">file</span> with <span class="token number">1</span><span class="token punctuation">..</span><span class="token number">2</span><span class="token punctuation">..</span><span class="token number">3</span>
&#x279C;  <span class="token function">git</span> git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> log --oneline                                  
5826c36 <span class="token punctuation">(</span>HEAD -<span class="token operator">&gt;</span> master<span class="token punctuation">)</span> INIT <span class="token builtin class-name">test</span> <span class="token function">file</span> with <span class="token number">1</span><span class="token punctuation">..</span><span class="token number">2</span><span class="token punctuation">..</span><span class="token number">3</span>
<span class="token comment"># &#x6216;&#x8005;&#x4F7F;&#x7528;&#x6587;&#x5B57;&#x56FE;&#x5F62;&#x5316;&#x754C;&#x9762;&#x6765;&#x663E;&#x793A;</span>
&#x279C;  <span class="token function">git</span> git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> log --graph
</code></pre>
<ol>
<li>&#x73B0;&#x5728;&#x6211;&#x60F3;&#x5C06;&#x7248;&#x672C;&#x56DE;&#x9000;&#x5230;<code>INIT</code>&#x7248;&#x672C;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#xFF1A;</li>
</ol>
<pre class="language-"><code class="lang-bash">&#x279C;  <span class="token function">git</span> git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> reset --hard HEAD^                              
HEAD is now at 5826c36 INIT <span class="token builtin class-name">test</span> <span class="token function">file</span> with <span class="token number">1</span><span class="token punctuation">..</span><span class="token number">2</span><span class="token punctuation">..</span><span class="token number">3</span>
* &#x6CE8;&#x610F;&#xFF1A;&#x4E00;&#x4E2A;&#x8131;&#x5B57;&#x7B26;<span class="token variable"><span class="token variable">`</span>^<span class="token variable">`</span></span>&#x4EE3;&#x8868;&#x56DE;&#x9000;&#x4E00;&#x4E2A;&#x7248;&#x672C;&#xFF0C;&#x56DE;&#x9000;&#x4E24;&#x4E2A;&#x7248;&#x672C;&#x4F7F;&#x7528;<span class="token variable"><span class="token variable">`</span>HEAD^^<span class="token variable">`</span></span>&#x5373;&#x53EF;
</code></pre>
<p>&#x5F53;&#x7136;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>HEAD~n</code>&#x6765;&#x56DE;&#x9000;&#x4E00;&#x4E2A;&#x6216;&#x8005;&#x591A;&#x4E2A;&#x7248;&#x672C;&#xFF0C;&#x5176;&#x4E2D;<code>n</code>&#x8868;&#x793A;&#x56DE;&#x9000;&#x7684;&#x7248;&#x672C;&#x6570;</p>
<p><strong>&#x4F46;&#x6211;&#x89C9;&#x5F97;&#x6BD4;&#x8F83;&#x597D;&#x7528;&#x7684;&#x662F;&#x4F7F;&#x7528;<code>commit hash-id</code>&#x53F7;&#x6765;&#x8FDB;&#x884C;&#x7248;&#x672C;&#x7684;&#x7CBE;&#x786E;&#x56DE;&#x9000;&#x6216;&#x8005;&#x524D;&#x8FDB;</strong></p>
<ol>
<li><code>git reflog</code>&#x547D;&#x4EE4;&#x53EF;&#x4EE5;&#x8BB0;&#x4F4F;&#x4F60;&#x6BCF;&#x4E00;&#x6B21;&#x7684;&#x63D0;&#x4EA4;&#x548C;&#x7248;&#x672C;&#x5207;&#x6362;&#x8BF7;&#x6C42;&#xFF1A;</li>
</ol>
<pre class="language-"><code class="lang-bash">&#x279C;  <span class="token function">git</span> git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> reflog          
5826c36 <span class="token punctuation">(</span>HEAD -<span class="token operator">&gt;</span> master<span class="token punctuation">)</span> HEAD@<span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span>: reset: moving to HEAD^
dadac05 HEAD@<span class="token punctuation">{</span><span class="token number">1</span><span class="token punctuation">}</span>: commit: INIT <span class="token builtin class-name">test</span> <span class="token function">file</span> with <span class="token number">4</span><span class="token punctuation">..</span>
5826c36 <span class="token punctuation">(</span>HEAD -<span class="token operator">&gt;</span> master<span class="token punctuation">)</span> HEAD@<span class="token punctuation">{</span><span class="token number">2</span><span class="token punctuation">}</span>: commit <span class="token punctuation">(</span>initial<span class="token punctuation">)</span>: INIT <span class="token builtin class-name">test</span> <span class="token function">file</span> with <span class="token number">1</span><span class="token punctuation">..</span><span class="token number">2</span><span class="token punctuation">..</span><span class="token number">3</span>
</code></pre>
<blockquote>
<p>&#x62D3;&#x5C55;&#x53C2;&#x8003;&#x8D44;&#x6599;&#xFF1A;</p>
<p><code>git log</code>&#x8BE6;&#x89E3;&#xFF1A;<a href="https://blog.csdn.net/jjlovefj/article/details/86476925" target="_blank">https://blog.csdn.net/jjlovefj/article/details/86476925</a></p>
<p><code>git log</code> &#x5B98;&#x65B9;&#x6587;&#x6863;&#xFF1A;<a href="https://git-scm.com/docs/git-log" target="_blank">https://git-scm.com/docs/git-log</a></p>
<p><code>git reset</code>&#x7684;&#x4E09;&#x79CD;&#x6A21;&#x5F0F;&#xFF1A;<a href="https://www.jianshu.com/p/c2ec5f06cf1a" target="_blank">https://www.jianshu.com/p/c2ec5f06cf1a</a></p>
</blockquote>
<h3 id="git-revert"><a name="git-revert" class="anchor-navigation-ex-anchor" href="#git-revert"><i class="fa fa-link" aria-hidden="true"></i></a>2.1.2. git revert</h3>
<p><code>git revert</code>&#x662F;&#x7528;&#x4E8E;&#x201C;&#x53CD;&#x505A;&#x201D;&#x67D0;&#x4E00;&#x4E2A;&#x7248;&#x672C;&#xFF0C;&#x4EE5;&#x8FBE;&#x5230;&#x64A4;&#x9500;&#x8BE5;&#x7248;&#x672C;&#x7684;&#x4FEE;&#x6539;&#x7684;&#x76EE;&#x7684;&#x3002;</p>
<p><strong>&#x9002;&#x7528;&#x573A;&#x666F;&#xFF1A;</strong>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x60F3;&#x64A4;&#x9500;&#x4E4B;&#x524D;&#x7684;&#x67D0;&#x4E00;&#x7248;&#x672C;&#xFF0C;&#x4F46;&#x662F;&#x53C8;&#x60F3;&#x4FDD;&#x7559;&#x8BE5;&#x76EE;&#x6807;&#x7248;&#x672C;&#x540E;&#x9762;&#x7684;&#x7248;&#x672C;&#xFF0C;&#x8BB0;&#x5F55;&#x4E0B;&#x8FD9;&#x6574;&#x4E2A;&#x7248;&#x672C;&#x53D8;&#x52A8;&#x6D41;&#x7A0B;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x7528;&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#xFF0C;&#x8FD9;&#x6B63;&#x662F;&#x548C;<code>reset</code>&#x4E0D;&#x540C;&#x7684;&#x5730;&#x65B9;.</p>
<p>&#x6BD4;&#x5982;&#xFF0C;&#x6211;&#x4EEC;commit&#x4E86;&#x4E09;&#x4E2A;&#x7248;&#x672C;&#xFF08;&#x7248;&#x672C;&#x4E00;&#x3001;&#x7248;&#x672C;&#x4E8C;&#x3001; &#x7248;&#x672C;&#x4E09;&#xFF09;&#xFF0C;&#x7A81;&#x7136;&#x53D1;&#x73B0;&#x7248;&#x672C;&#x4E8C;&#x4E0D;&#x884C;&#xFF08;&#x5982;&#xFF1A;&#x6709;bug&#xFF09;&#xFF0C;&#x60F3;&#x8981;&#x64A4;&#x9500;&#x7248;&#x672C;&#x4E8C;&#xFF0C;&#x4F46;&#x53C8;&#x4E0D;&#x60F3;&#x5F71;&#x54CD;&#x64A4;&#x9500;&#x7248;&#x672C;&#x4E09;&#x7684;&#x63D0;&#x4EA4;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x7528; git revert &#x547D;&#x4EE4;&#x6765;&#x53CD;&#x505A;&#x7248;&#x672C;&#x4E8C;&#xFF0C;&#x751F;&#x6210;&#x65B0;&#x7684;&#x7248;&#x672C;&#x56DB;&#xFF0C;&#x8FD9;&#x4E2A;&#x7248;&#x672C;&#x56DB;&#x91CC;&#x4F1A;&#x4FDD;&#x7559;&#x7248;&#x672C;&#x4E09;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x4F46;&#x64A4;&#x9500;&#x4E86;&#x7248;&#x672C;&#x4E8C;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x5728;&#x8FD9;&#x91CC;&#x5C06;&#x95EE;&#x9898;&#x7B80;&#x5316;&#x5982;&#x4E0B;&#xFF1A;</p>
<ol>
<li>&#x63D0;&#x4EA4;&#x4E09;&#x6B21;&#xFF0C;&#x5BF9;&#x5E94;&#x7248;&#x672C;&#x5206;&#x522B;&#x4E3A;<code>version 1..2..3</code></li>
</ol>
<pre class="language-"><code class="lang-bash">&#x279C;  test02 git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> log --oneline   
74c4ae3 <span class="token punctuation">(</span>HEAD -<span class="token operator">&gt;</span> master, tag: v3.0<span class="token punctuation">)</span> publish version <span class="token number">3</span>
46ed99f <span class="token punctuation">(</span>tag: v2.0<span class="token punctuation">)</span> publish version <span class="token number">2</span>
4bb0e96 <span class="token punctuation">(</span>tag: v1.0<span class="token punctuation">)</span> publish version <span class="token number">1</span>
</code></pre>
<ol>
<li>&#x56E0;&#x4E3A;&#x67D0;&#x4E9B;&#x539F;&#x56E0;&#x6211;&#x4E0D;&#x60F3;&#x8981;&#x7248;&#x672C;&#x4E8C;<code>v2.0</code>&#xFF0C;&#x6B64;&#x65F6;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>revert</code>&#x7248;&#x672C;&#x4E8C;&#x6765;&#x5B9E;&#x73B0;&#xFF0C;&#x8FD9;&#x91CC;&#x4F7F;&#x7528;<code>-n</code>&#x53C2;&#x6570;&#x52A0;&#x4E0A;<code>commit id</code></li>
</ol>
<pre class="language-"><code class="lang-bash">&#x279C;  test02 git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> revert -n 46ed99f
</code></pre>
<p>&#x53CD;&#x505A;&#x65F6;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x6709;&#x51B2;&#x7A81;&#x53D1;&#x751F;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x9700;&#x8981;&#x624B;&#x52A8;&#x89E3;&#x51B3;&#x51B2;&#x7A81;</p>
<ol>
<li>&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</li>
</ol>
<pre class="language-"><code class="lang-bash">&#x279C;  test02 git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span>  <span class="token function">git</span> <span class="token function">add</span> <span class="token builtin class-name">.</span>
&#x279C;  test02 git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span>  <span class="token function">git</span> commit -m <span class="token string">&quot;remove version 2&quot;</span>
</code></pre>
<p>&#x81F3;&#x6B64;&#xFF0C;<code>revert</code>&#x5C31;&#x5B8C;&#x6210;&#x4E86;.</p>
<h2 id="&#x7BA1;&#x7406;&#x4FEE;&#x6539;"><a name="&#x7BA1;&#x7406;&#x4FEE;&#x6539;" class="anchor-navigation-ex-anchor" href="#&#x7BA1;&#x7406;&#x4FEE;&#x6539;"><i class="fa fa-link" aria-hidden="true"></i></a>2.2. &#x7BA1;&#x7406;&#x4FEE;&#x6539;</h2>
<p>&#x64A4;&#x9500;&#x5DE5;&#x4F5C;&#x533A;&#x7684;&#x4FEE;&#x6539;&#x6709;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#xFF1A;</p>
<ul>
<li>&#x4E00;&#x79CD;&#x662F;&#x81EA;&#x6587;&#x4EF6;&#x4FEE;&#x6539;&#x540E;&#x8FD8;&#x6CA1;&#x6709;&#x88AB;&#x653E;&#x5230;&#x6682;&#x5B58;&#x533A;&#xFF0C;&#x64A4;&#x9500;&#x4FEE;&#x6539;&#x5C31;&#x56DE;&#x5230;&#x548C;&#x7248;&#x672C;&#x5E93;&#x4E00;&#x6A21;&#x4E00;&#x6837;&#x7684;&#x72B6;&#x6001;</li>
<li>&#x53E6;&#x4E00;&#x79CD;&#x662F;&#x6587;&#x4EF6;&#x5DF2;&#x7ECF;&#x6DFB;&#x52A0;&#x5230;&#x6682;&#x5B58;&#x533A;&#x540E;&#xFF0C;&#x53C8;&#x4F5C;&#x4E86;&#x4FEE;&#x6539;&#xFF0C;&#x64A4;&#x9500;&#x4FEE;&#x6539;&#x5C31;&#x56DE;&#x5230;&#x6DFB;&#x52A0;&#x5230;&#x6682;&#x5B58;&#x533A;&#x540E;&#x7684;&#x72B6;&#x6001;</li>
</ul>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> checkout -- <span class="token builtin class-name">test</span>
* &#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF1A;<span class="token variable"><span class="token variable">`</span>--<span class="token variable">`</span></span>&#x4E0D;&#x53EF;&#x5C11;&#xFF0C;&#x4E14;&#x524D;&#x540E;&#x90FD;&#x8981;&#x6709;&#x7A7A;&#x683C;
</code></pre>
<p>&#x5220;&#x9664;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token comment"># &#x5982;&#x679C;&#x4F60;&#x786E;&#x5B9A;&#x5220;&#x9664;&#x672C;&#x5730;&#x5DE5;&#x4F5C;&#x533A;&#x7684;&#x67D0;&#x4E2A;&#x6587;&#x4EF6;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;rm&#x547D;&#x4EE4;&#x6765;&#x5220;&#x9664;</span>
<span class="token function">rm</span> hello
<span class="token comment"># &#x5982;&#x679C;&#x4F60;&#x53EA;&#x60F3;&#x5220;&#x9664;&#x4ED3;&#x5E93;&#x4E2D;&#x7684;&#x67D0;&#x4E2A;&#x6216;&#x8005;&#x67D0;&#x4E9B;&#x6587;&#x4EF6;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;</span>
&#x279C;  <span class="token function">git</span> git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> <span class="token function">rm</span> hello                                        
<span class="token function">rm</span> <span class="token string">&apos;hello&apos;</span>
<span class="token comment"># &#x67E5;&#x770B;&#x5F53;&#x524D;&#x72B6;&#x6001;</span>
&#x279C;  <span class="token function">git</span> git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> &#x2717; <span class="token function">git</span> status                                        
On branch master
Changes to be committed:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git reset HEAD &lt;file&gt;...&quot;</span> to unstage<span class="token punctuation">)</span>

        deleted:    hello
</code></pre>
<h1 id="git&#x5206;&#x652F;&#x7BA1;&#x7406;"><a name="git&#x5206;&#x652F;&#x7BA1;&#x7406;" class="anchor-navigation-ex-anchor" href="#git&#x5206;&#x652F;&#x7BA1;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>3. Git&#x5206;&#x652F;&#x7BA1;&#x7406;</h1>
<h2 id="&#x521B;&#x5EFA;&#x67E5;&#x770B;&#x5207;&#x6362;&#x5408;&#x5E76;&#x5220;&#x9664;&#x5206;&#x652F;"><a name="&#x521B;&#x5EFA;&#x67E5;&#x770B;&#x5207;&#x6362;&#x5408;&#x5E76;&#x5220;&#x9664;&#x5206;&#x652F;" class="anchor-navigation-ex-anchor" href="#&#x521B;&#x5EFA;&#x67E5;&#x770B;&#x5207;&#x6362;&#x5408;&#x5E76;&#x5220;&#x9664;&#x5206;&#x652F;"><i class="fa fa-link" aria-hidden="true"></i></a>3.1. &#x521B;&#x5EFA;&#x67E5;&#x770B;&#x5207;&#x6362;&#x5408;&#x5E76;&#x5220;&#x9664;&#x5206;&#x652F;</h2>
<p>&#x521B;&#x5EFA;&#x4E00;&#x4E2A;<code>dev</code>&#x5206;&#x652F;&#xFF0C;&#x5E76;&#x5207;&#x6362;&#x81F3;<code>dev</code>&#x5206;&#x652F;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> checkout -b dev
<span class="token comment"># &#x8FD9;&#x6761;&#x547D;&#x4EE4;&#x76F8;&#x5F53;&#x4E8E;</span>
<span class="token function">git</span> branch dev
<span class="token function">git</span> checkout dev

<span class="token comment"># &#x65B0;&#x7248;&#x672C;&#x7684;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;switch&#x6765;&#x521B;&#x5EFA;&#x5207;&#x6362;&#x5206;&#x652F;</span>
<span class="token comment"># &#x521B;&#x5EFA;&#x5E76;&#x5207;&#x6362;&#x81F3;dev&#x5206;&#x652F;</span>
<span class="token function">git</span> switch -c dev
</code></pre>
<p>&#x67E5;&#x770B;&#x5206;&#x652F;</p>
<pre class="language-"><code class="lang-bash"><span class="token comment"># &#x67E5;&#x770B;&#x5F53;&#x524D;&#x5206;&#x652F;</span>
<span class="token function">git</span> branch
<span class="token comment"># &#x67E5;&#x770B;&#x6240;&#x6709;&#x5206;&#x652F;</span>
<span class="token function">git</span> branch -a
</code></pre>
<p>&#x4FEE;&#x6539;&#x5B8C;&#x5F53;&#x524D;&#x5206;&#x652F;&#x5207;&#x6362;&#x4E3A;&#x4E3B;&#x5206;&#x652F;&#x6216;&#x8005;&#x5176;&#x4ED6;&#x5206;&#x533A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> checkout master
<span class="token comment"># &#x6216;&#x8005;&#x4F7F;&#x7528;switch&#x5207;&#x6362;&#x5206;&#x652F;</span>
<span class="token function">git</span> switch dev
</code></pre>
<p>&#x5408;&#x5E76;<code>dev</code>&#x5206;&#x652F;&#x4E0A;&#x7684;&#x4FEE;&#x6539;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> merge dev
</code></pre>
<p>&#x5220;&#x9664;<code>dev</code>&#x5206;&#x652F;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> branch -d dev
</code></pre>
<p>&#x5F3A;&#x5236;&#x5220;&#x9664;&#x5206;&#x652F;</p>
<pre class="language-"><code class="lang-bash">* &#x4F7F;&#x7528;&#x573A;&#x666F;&#x4E4B;&#x4E00;&#xFF1A;&#x4E3A;&#x4EA7;&#x54C1;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x65B0;&#x529F;&#x80FD;&#xFF0C;&#x65B0;&#x529F;&#x80FD;&#x5206;&#x652F;&#x8FDB;&#x884C;&#x5230;&#x4E00;&#x534A;&#x7A81;&#x7136;&#x88AB;&#x544A;&#x77E5;&#x8981;&#x53D6;&#x6D88;&#x8BE5;&#x529F;&#x80FD;&#x7684;&#x5F00;&#x53D1;&#xFF0C;&#x6B64;&#x65F6;&#x8BE5;&#x5206;&#x652F;&#x8FD8;&#x672A;&#x5408;&#x5E76;&#x5230;&#x4E3B;&#x5206;&#x652F;&#xFF0C;&#x9700;&#x8981;&#x8FDB;&#x884C;&#x5220;&#x9664;&#xFF0C;&#x800C;&#x4F7F;&#x7528;<span class="token variable"><span class="token variable">`</span>-d<span class="token variable">`</span></span>&#x5220;&#x9664;&#x5206;&#x652F;&#x4F1A;&#x62A5;&#x9519;&#x4ECE;&#x800C;&#x65E0;&#x6CD5;&#x5220;&#x9664;&#xFF0C;&#x6240;&#x4EE5;&#x6B64;&#x65F6;&#x5C31;&#x9700;&#x8981;&#x5F3A;&#x5236;&#x5220;&#x9664;&#x5206;&#x652F;
<span class="token function">git</span> branch -D dev
</code></pre>
<h2 id="&#x5206;&#x652F;&#x7BA1;&#x7406;&#x7B56;&#x7565;"><a name="&#x5206;&#x652F;&#x7BA1;&#x7406;&#x7B56;&#x7565;" class="anchor-navigation-ex-anchor" href="#&#x5206;&#x652F;&#x7BA1;&#x7406;&#x7B56;&#x7565;"><i class="fa fa-link" aria-hidden="true"></i></a>3.2. &#x5206;&#x652F;&#x7BA1;&#x7406;&#x7B56;&#x7565;</h2>
<p>&#x901A;&#x5E38;&#xFF0C;&#x5408;&#x5E76;&#x5206;&#x652F;&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x53EF;&#x80FD;&#xFF0C;Git&#x4F1A;&#x7528;<code>Fast forward</code>&#x6A21;&#x5F0F;&#xFF0C;&#x4F46;&#x8FD9;&#x79CD;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x5220;&#x9664;&#x5206;&#x652F;&#x540E;&#xFF0C;&#x4F1A;&#x4E22;&#x6389;&#x5206;&#x652F;&#x4FE1;&#x606F;&#x3002;&#x5982;&#x679C;&#x8981;&#x5F3A;&#x5236;&#x7981;&#x7528;<code>Fast forward</code>&#x6A21;&#x5F0F;&#xFF0C;Git&#x5C31;&#x4F1A;&#x5728;merge&#x65F6;&#x751F;&#x6210;&#x4E00;&#x4E2A;&#x65B0;&#x7684;commit&#xFF0C;&#x8FD9;&#x6837;&#xFF0C;&#x4ECE;&#x5206;&#x652F;&#x5386;&#x53F2;&#x4E0A;&#x5C31;&#x53EF;&#x4EE5;&#x770B;&#x51FA;&#x5206;&#x652F;&#x4FE1;&#x606F;</p>
<p>&#x4F8B;&#x5982;&#xFF1A;&#x5728;<code>dev</code>&#x5206;&#x652F;&#x4E0A;&#x505A;&#x4E86;&#x4E9B;&#x8BB8;&#x4FEE;&#x6539;&#xFF0C;&#x7136;&#x540E;&#x5207;&#x6362;&#x81F3;<code>master</code>&#x5206;&#x652F;&#x5408;&#x5E76;<code>dev</code></p>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> merge --no-ff -m <span class="token string">&quot;merge with no-ff&quot;</span> dev
</code></pre>
<p>&#x67E5;&#x770B;&#x5206;&#x652F;&#x60C5;&#x51B5;</p>
<pre class="language-"><code class="lang-bash">&#x279C;  <span class="token builtin class-name">test</span> git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> log --graph --pretty<span class="token operator">=</span>oneline --abbrev-commit                                                        
*   8c19649 <span class="token punctuation">(</span>HEAD -<span class="token operator">&gt;</span> master<span class="token punctuation">)</span> merge with no-ff
<span class="token operator">|</span><span class="token punctuation">\</span>
<span class="token operator">|</span> * 17ae26b <span class="token punctuation">(</span>fun2<span class="token punctuation">)</span> some change <span class="token keyword">in</span> README on fun2 branch
<span class="token operator">|</span>/
*   e5e20a0 fix conflict
<span class="token operator">|</span><span class="token punctuation">\</span>
<span class="token operator">|</span> * 1f22afc changes <span class="token keyword">in</span> README
* <span class="token operator">|</span> 913ffd6 changes <span class="token keyword">in</span> README
<span class="token operator">|</span>/
* 0bef827 Add branch_dev
* f377044 <span class="token punctuation">(</span>origin/master, origin/HEAD<span class="token punctuation">)</span> Add README
</code></pre>
<p>&#x53EF;&#x4EE5;&#x660E;&#x663E;&#x770B;&#x5230;&#x4E00;&#x6B21;&#x5408;&#x5E76;&#x5206;&#x652F;&#x7684;&#x63D0;&#x4EA4;</p>
<h2 id="bug&#x5206;&#x652F;"><a name="bug&#x5206;&#x652F;" class="anchor-navigation-ex-anchor" href="#bug&#x5206;&#x652F;"><i class="fa fa-link" aria-hidden="true"></i></a>3.3. BUG&#x5206;&#x652F;</h2>
<p>&#x5728;Git&#x4E2D;&#xFF0C;&#x6BCF;&#x4E2A;bug&#x90FD;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x4E34;&#x65F6;&#x5206;&#x652F;&#x6765;&#x4FEE;&#x590D;&#xFF0C;&#x4FEE;&#x590D;&#x540E;&#xFF0C;&#x5408;&#x5E76;&#x5206;&#x652F;&#xFF0C;&#x7136;&#x540E;&#x5C06;&#x4E34;&#x65F6;&#x5206;&#x652F;&#x5220;&#x9664;&#x3002;</p>
<p>&#x5F53;&#x4F60;&#x5F00;&#x53D1;&#x65F6;&#x4E34;&#x65F6;&#x63A5;&#x5230;&#x4E00;&#x4E2A;&#x4FEE;&#x590D;bug&#x5206;&#x652F;&#x7684;&#x4EFB;&#x52A1;&#x65F6;&#xFF0C;&#x6B64;&#x65F6;&#x4F60;&#x4F1A;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;<code>issue-01</code>&#x5206;&#x652F;&#x6765;&#x4FEE;&#x590D;&#x5B83;&#xFF0C;&#x4F46;&#x662F;&#x6B64;&#x65F6;&#x4F60;&#x5728;&#x5F53;&#x524D;&#x5206;&#x652F;&#x4E0A;&#x7684;&#x4EFB;&#x52A1;&#x8FD8;&#x672A;&#x63D0;&#x4EA4;&#x3002;</p>
<pre class="language-"><code class="lang-bash">&#x279C;  <span class="token builtin class-name">test</span> git:<span class="token punctuation">(</span>fun2<span class="token punctuation">)</span> &#x2717; <span class="token function">git</span> status 
On branch fun2
Changes not staged <span class="token keyword">for</span> commit:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git add &lt;file&gt;...&quot;</span> to update what will be committed<span class="token punctuation">)</span>
  <span class="token punctuation">(</span>use <span class="token string">&quot;git checkout -- &lt;file&gt;...&quot;</span> to discard changes <span class="token keyword">in</span> working directory<span class="token punctuation">)</span>

        modified:   branch_dev

no changes added to commit <span class="token punctuation">(</span>use <span class="token string">&quot;git add&quot;</span> and/or <span class="token string">&quot;git commit -a&quot;</span><span class="token punctuation">)</span>
</code></pre>
<p>&#x8FD9;&#x65F6;&#xFF0C;&#x4F60;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;Git&#x7684;<code>stash</code>&#x529F;&#x80FD;&#x6765;&#x6682;&#x505C;&#x5E76;&#x9690;&#x85CF;&#x5F53;&#x524D;&#x5206;&#x652F;&#x4E0A;&#x7684;&#x5DE5;&#x4F5C;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">&#x279C;  <span class="token builtin class-name">test</span> git:<span class="token punctuation">(</span>fun2<span class="token punctuation">)</span> &#x2717; <span class="token function">git</span> stash 
Saved working directory and index state WIP on fun2: 17ae26b some change <span class="token keyword">in</span> README on fun2 branch
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x5F53;&#x524D;&#x5DE5;&#x4F5C;&#x533A;&#x7684;&#x4FEE;&#x6539;&#x5DF2;&#x7ECF;&#x88AB;&#x9690;&#x85CF;&#x4E86;&#x8D77;&#x6765;</p>
<p>&#x63A5;&#x4E0B;&#x6765;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x6109;&#x5FEB;&#x7684;&#x4FEE;&#x590D;BUG&#x4E86;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token comment"># &#x786E;&#x5B9A;&#x5728;&#x90A3;&#x4E2A;&#x5206;&#x652F;&#x4E0A;&#x4FEE;&#x590D;BUg</span>
<span class="token function">git</span> checkout master
<span class="token comment"># &#x521B;&#x5EFA;BUG&#x5206;&#x652F;</span>
<span class="token function">git</span> checkout -b issue-01

<span class="token comment"># &#x4FEE;&#x590D;BUG</span>
<span class="token punctuation">..</span>.
<span class="token comment"># &#x63D0;&#x4EA4;&#x4FEE;&#x590D;BUG&#x7684;&#x4FEE;&#x6539;</span>
<span class="token punctuation">..</span>.
<span class="token comment"># &#x5207;&#x6362;&#x5230;master&#x4E3B;&#x5206;&#x652F;&#x5B8C;&#x6210;&#x5408;&#x5E76;</span>
<span class="token function">git</span> merge --no-ff -m <span class="token string">&quot;merged fix bug 01&quot;</span> issue-01
</code></pre>
<p>&#x641E;&#x5B8C;&#x4E4B;&#x540E;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x56DE;&#x5230;&#x81EA;&#x5DF1;&#x7684;&#x5DE5;&#x4F5C;&#x5206;&#x652F;&#x7EE7;&#x7EED;&#x5DE5;&#x4F5C;&#x4E86;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">&#x279C;  <span class="token builtin class-name">test</span> git:<span class="token punctuation">(</span>fun2<span class="token punctuation">)</span> <span class="token function">git</span> status                                                                                                         
On branch fun2
nothing to commit, working tree clean
<span class="token comment"># &#x5217;&#x51FA;&#x4E4B;&#x524D;&#x6240;&#x4FDD;&#x5B58;&#x7684;&#x5DE5;&#x4F5C;&#x533A;&#x4FE1;&#x606F;</span>
&#x279C;  <span class="token builtin class-name">test</span> git:<span class="token punctuation">(</span>fun2<span class="token punctuation">)</span> <span class="token function">git</span> stash list
stash@<span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span>: WIP on fun2: 17ae26b some change <span class="token keyword">in</span> README on fun2 branch
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x5DE5;&#x4F5C;&#x73B0;&#x573A;&#x8FD8;&#x5728;&#xFF0C;&#x4F46;&#x662F;&#x9700;&#x8981;&#x624B;&#x52A8;&#x6062;&#x590D;&#x4E00;&#x4E0B;&#xFF0C;&#x6709;&#x4E24;&#x79CD;&#x65B9;&#x6CD5;&#xFF1A;</p>
<ul>
<li>&#x4F7F;&#x7528;<code>git stash apply</code>&#x6062;&#x590D;&#xFF0C;&#x4F46;&#x662F;&#x6062;&#x590D;&#x4E4B;&#x540E;&#xFF0C;stash&#x7684;&#x5185;&#x5BB9;&#x5E76;&#x4E0D;&#x4F1A;&#x88AB;&#x5220;&#x9664;&#xFF0C;&#x9700;&#x8981;&#x624B;&#x52A8;&#x4F7F;&#x7528;<code>git stash drop</code>&#x6765;&#x5220;&#x9664;</li>
<li>&#x4F7F;&#x7528;<code>git stash pop</code>&#xFF0C;&#x6062;&#x590D;&#x7684;&#x540C;&#x65F6;&#x628A;stash&#x5185;&#x5BB9;&#x4E5F;&#x987A;&#x4FBF;&#x5220;&#x4E86;</li>
</ul>
<h2 id="git-rebase"><a name="git-rebase" class="anchor-navigation-ex-anchor" href="#git-rebase"><i class="fa fa-link" aria-hidden="true"></i></a>3.4. Git Rebase</h2>
<p><strong>&#x5E94;&#x7528;&#x573A;&#x666F;&#x4E00;&#xFF1A;</strong>&#x7528;&#x4E8E;&#x5408;&#x5E76;&#x591A;&#x6B21;&#x63D0;&#x4EA4;&#x8BB0;&#x5F55;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x6BCF;&#x4E00;&#x6B21;&#x529F;&#x80FD;&#x5F00;&#x53D1;&#xFF0C; &#x5BF9;&#x591A;&#x4E2A; commit &#x8FDB;&#x884C;&#x5408;&#x5E76;&#x5904;&#x7406;</p>
<ol>
<li>&#x5408;&#x5E76;&#x6700;&#x8FD1;3&#x6B21;&#x7684;&#x63D0;&#x4EA4;&#x8BB0;&#x5F55;</li>
</ol>
<pre class="language-"><code class="lang-bash"> <span class="token function">git</span> rebase -i  <span class="token punctuation">[</span>startpoint<span class="token punctuation">]</span>  <span class="token punctuation">[</span>endpoint<span class="token punctuation">]</span>
* &#x6CE8;&#x610F;&#xFF1A;&#x5176;&#x4E2D;<span class="token variable"><span class="token variable">`</span>-i<span class="token variable">`</span></span>&#x7684;&#x610F;&#x601D;&#x662F;<span class="token variable"><span class="token variable">`</span>--interactive<span class="token variable">`</span></span>&#x4EA4;&#x4E92;&#x5F0F;&#x4FEE;&#x6539;&#xFF0C;<span class="token punctuation">[</span>startpoint<span class="token punctuation">]</span>&#x548C;  <span class="token punctuation">[</span>endpoint<span class="token punctuation">]</span>&#x6307;&#x5B9A;&#x4E86;&#x4E00;&#x4E2A;&#x7F16;&#x8F91;&#x533A;&#x95F4;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x6307;&#x5B9A;<span class="token punctuation">[</span>endpoint<span class="token punctuation">]</span>&#xFF0C;&#x5219;&#x9ED8;&#x8BA4;&#x4F1A;&#x4F7F;&#x7528;&#x5F53;&#x524D;HEAD&#x6307;&#x9488;&#x5904;&#x7684;commit&#x63D0;&#x4EA4;
&#x279C;  test01 git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> rebase -i HEAD~3
Successfully rebased and updated refs/heads/master.

<span class="token comment"># &#x6216;&#x8005;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x53EF;&#x4EE5;&#x8FBE;&#x5230;&#x76F8;&#x540C;&#x7684;&#x6548;&#x679C;</span>
<span class="token function">git</span> rebase -i 0ad1d42
</code></pre>
<ol>
<li>&#x8FD9;&#x65F6;&#xFF0C;&#x4F1A;&#x81EA;&#x52A8;&#x8FDB;&#x5165;<code>vi</code>&#x7F16;&#x8F91;&#x6A21;&#x5F0F;&#xFF0C;&#x7136;&#x540E;&#x8FDB;&#x884C;&#x76F8;&#x5E94;&#x4FEE;&#x6539;&#x5373;&#x53EF;&#xFF0C;&#x8FD9;&#x91CC;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x4E00;&#x4E9B;&#x547D;&#x4EE4;&#xFF1A;</li>
</ol>
<pre class="language-"><code class="lang-bash">pick&#xFF1A;&#x4FDD;&#x7559;&#x8BE5;commit&#xFF08;&#x7F29;&#x5199;:p&#xFF09;
reword&#xFF1A;&#x4FDD;&#x7559;&#x8BE5;commit&#xFF0C;&#x4F46;&#x6211;&#x9700;&#x8981;&#x4FEE;&#x6539;&#x8BE5;commit&#x7684;&#x6CE8;&#x91CA;&#xFF08;&#x7F29;&#x5199;:r&#xFF09;
edit&#xFF1A;&#x4FDD;&#x7559;&#x8BE5;commit, &#x4F46;&#x6211;&#x8981;&#x505C;&#x4E0B;&#x6765;&#x4FEE;&#x6539;&#x8BE5;&#x63D0;&#x4EA4;<span class="token punctuation">(</span>&#x4E0D;&#x4EC5;&#x4EC5;&#x4FEE;&#x6539;&#x6CE8;&#x91CA;<span class="token punctuation">)</span>&#xFF08;&#x7F29;&#x5199;:e&#xFF09;
squash&#xFF1A;&#x5C06;&#x8BE5;commit&#x548C;&#x524D;&#x4E00;&#x4E2A;commit&#x5408;&#x5E76;&#xFF08;&#x7F29;&#x5199;:s&#xFF09;
fixup&#xFF1A;&#x5C06;&#x8BE5;commit&#x548C;&#x524D;&#x4E00;&#x4E2A;commit&#x5408;&#x5E76;&#xFF0C;&#x4F46;&#x6211;&#x4E0D;&#x8981;&#x4FDD;&#x7559;&#x8BE5;&#x63D0;&#x4EA4;&#x7684;&#x6CE8;&#x91CA;&#x4FE1;&#x606F;&#xFF08;&#x7F29;&#x5199;:f&#xFF09;
exec&#xFF1A;&#x6267;&#x884C;shell&#x547D;&#x4EE4;&#xFF08;&#x7F29;&#x5199;:x&#xFF09;
drop&#xFF1A;&#x6211;&#x8981;&#x4E22;&#x5F03;&#x8BE5;commit&#xFF08;&#x7F29;&#x5199;:d&#xFF09;
</code></pre>
<ol>
<li>&#x5982;&#x679C;&#x4F60;&#x4FDD;&#x5B58;&#x65F6;&#x5F02;&#x5E38;&#x9000;&#x51FA;&#x4E86;&#x6216;&#x8005;&#x4FDD;&#x5B58;&#x9000;&#x51FA;&#x662F;&#x51FA;&#x73B0;&#x4E86;&#x9519;&#x8BEF;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>git rebase --edit-todo</code>&#x6765;&#x91CD;&#x65B0;&#x4FEE;&#x6539;&#x63D0;&#x4EA4;&#xFF0C;&#x8FD9;&#x65F6;&#x4F60;&#x5C06;&#x4E00;&#x76F4;&#x5904;&#x4E8E;&#x7F16;&#x8F91;&#x6A21;&#x5F0F;&#x4E2D;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>git rebase --continue</code>&#x56DE;&#x53BB;&#x7EE7;&#x7EED;&#x8FDB;&#x884C;&#x7F16;&#x8F91;&#x64CD;&#x4F5C;</li>
<li>&#x4F7F;&#x7528;<code>git log</code>&#x67E5;&#x770B;&#x63D0;&#x4EA4;&#x5408;&#x5E76;&#x540E;&#x7684;&#x6548;&#x679C;</li>
</ol>
<p><strong>&#x5E94;&#x7528;&#x573A;&#x666F;&#x4E8C;&#xFF1A;</strong>&#x5408;&#x5E76;&#x5206;&#x652F;</p>
<p>&#x4F7F;&#x7528;<code>merge</code>&#x6765;&#x5408;&#x5E76;&#x5206;&#x652F;&#x65F6;&#x4F1A;&#x65B0;&#x589E;&#x4E00;&#x6761;&#x63D0;&#x4EA4;&#x8BB0;&#x5F55;&#xFF0C;&#x4F46;&#x662F;&#x6709;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x89C9;&#x5F97;&#x8FD9;&#x6837;&#x7684;&#x63D0;&#x4EA4;&#x8BB0;&#x5F55;&#x5E76;&#x65E0;&#x5375;&#x7528;&#xFF0C;&#x8FD9;&#x65F6;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x60F3;&#x8981;&#x4FDD;&#x6301;&#x4E00;&#x4E2A;&#x6E05;&#x6D01;&#x7684;commit&#x73AF;&#x5883;&#xFF0C;&#x5C31;&#x5F97;&#x4F7F;&#x7528;<code>rebase</code>&#x4E86;</p>
<p>&#x573A;&#x666F;&#xFF1A;<a href="../home/suofeiya/myGitbook/images/git%20rebase01-1575858760087.png" data-lightbox="d0134f0b-8b10-4d99-aece-7d9693c9ce4b" data-title=""><img src="../home/suofeiya/myGitbook/images/git%20rebase01-1575858760087.png" alt=""></a></p>
<p>&#x4E00;&#x4E2A;&#x9879;&#x76EE;&#xFF0C;&#x5F53;&#x524D;&#x4F60;&#x6B63;&#x5728;&#x5F00;&#x53D1;<code>feature1</code>&#x5206;&#x652F;&#xFF0C;&#x4F46;&#x6B64;&#x65F6;<code>master</code>&#x4E3B;&#x5206;&#x652F;&#x4E0A;&#x6025;&#x6709;&#x4E00;&#x4E2A;BUG&#x9700;&#x8981;&#x4FEE;&#x590D;&#xFF0C;&#x4F60;&#x7684;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x540C;&#x4E8B;&#x4FEE;&#x590D;&#x5B8C;&#x8BE5;BUG&#x540E;&#x8FDB;&#x884C;&#x4E86;&#x4E00;&#x6B21;&#x63D0;&#x4EA4;&#xFF0C;&#x6B64;&#x65F6;<code>master</code>&#x5206;&#x652F;&#x5DF2;&#x7ECF;&#x9886;&#x5148;&#x4E8E;&#x4F60;&#x5F53;&#x524D;&#x7684;<code>feature1</code>&#x5206;&#x652F;</p>
<p>&#x5728;<code>feature</code>&#x5206;&#x652F;&#x4E0A;&#x4F7F;&#x7528;<code>rebase</code>&#x5408;&#x5E76;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> rebase master
</code></pre>
<p><code>rebase</code>&#x5177;&#x4F53;&#x8FDB;&#x884C;&#x7684;&#x64CD;&#x4F5C;&#xFF1A;</p>
<ol>
<li><p><code>git</code> &#x4F1A;&#x628A; <code>feature1</code> &#x5206;&#x652F;&#x91CC;&#x9762;&#x7684;&#x6BCF;&#x4E2A; <code>commit</code> &#x53D6;&#x6D88;&#x6389;</p>
</li>
<li><p>&#x628A;&#x4E0A;&#x9762;&#x7684;&#x64CD;&#x4F5C;&#x4E34;&#x65F6;&#x4FDD;&#x5B58;&#x6210; <code>patch</code> &#x6587;&#x4EF6;&#xFF0C;&#x5B58;&#x5728; <code>.git/rebase</code> &#x76EE;&#x5F55;&#x4E0B;</p>
</li>
<li><p>&#x628A; <code>feature1</code> &#x5206;&#x652F;&#x66F4;&#x65B0;&#x5230;&#x6700;&#x65B0;&#x7684; <code>master</code> &#x5206;&#x652F;</p>
</li>
<li><p>&#x628A;&#x4E0A;&#x9762;&#x4FDD;&#x5B58;&#x7684; <code>patch</code> &#x6587;&#x4EF6;&#x5E94;&#x7528;&#x5230; <code>feature1</code> &#x5206;&#x652F;&#x4E0A;</p>
</li>
</ol>
<p>-- <strong>&#x53D6;&#x6D88;rebase&#x64CD;&#x4F5C;&#x4F7F;&#x7528;<code>git rebase --abort</code></strong> &#x547D;&#x4EE4;--</p>
<h2 id="&#x8FDC;&#x7A0B;&#x5206;&#x652F;&#x7BA1;&#x7406;"><a name="&#x8FDC;&#x7A0B;&#x5206;&#x652F;&#x7BA1;&#x7406;" class="anchor-navigation-ex-anchor" href="#&#x8FDC;&#x7A0B;&#x5206;&#x652F;&#x7BA1;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>3.5. &#x8FDC;&#x7A0B;&#x5206;&#x652F;&#x7BA1;&#x7406;</h2>
<p>&#x67E5;&#x770B;&#x8FDC;&#x7A0B;&#x5E93;&#x7684;&#x4FE1;&#x606F;&#xFF0C;&#x4F7F;&#x7528;<code>git remote</code>&#xFF0C;&#x4F7F;&#x7528;<code>-v</code>&#x53EF;&#x4EE5;&#x663E;&#x793A;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;</p>
<pre class="language-"><code class="lang-bash">&#x279C;  <span class="token builtin class-name">test</span> git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> remote -v  
origin  https://github.com/AGou-ops/test.git <span class="token punctuation">(</span>fetch<span class="token punctuation">)</span>
origin  https://github.com/AGou-ops/test.git <span class="token punctuation">(</span>push<span class="token punctuation">)</span>            <span class="token comment"># &#x5982;&#x679C;&#x6CA1;&#x6709;push&#x6743;&#x9650;&#xFF0C;&#x770B;&#x4E0D;&#x5230;&#x8BE5;&#x884C;&#x5185;&#x5BB9;</span>
</code></pre>
<p>&#x63A8;&#x9001;&#x5206;&#x652F;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> push origin <span class="token punctuation">[</span>BRANCH_NAME<span class="token punctuation">]</span>
</code></pre>
<p>&#x534F;&#x540C;&#x5F00;&#x53D1;<code>dev</code>&#x5206;&#x652F;</p>
<pre class="language-"><code class="lang-bash"><span class="token comment"># &#x62C9;&#x53D6;&#x8FDC;&#x7A0B;&#x5206;&#x652F;</span>
<span class="token function">git</span> clone https://github.com/AGou-ops/test.git
<span class="token comment"># &#x6B64;&#x65F6;&#x53EA;&#x80FD;&#x770B;&#x5230;`master`&#x5206;&#x652F;</span>
<span class="token comment"># &#x5982;&#x679C;&#x60F3;&#x8981;&#x5728;dev&#x5206;&#x652F;&#x4E0A;&#x8FDB;&#x884C;&#x5F00;&#x53D1;&#xFF0C;&#x5C31;&#x5FC5;&#x987B;&#x521B;&#x5EFA;&#x8FDC;&#x7A0B;`origin`&#x7684;`dev`&#x5206;&#x652F;</span>
<span class="token function">git</span> checkout -b dev origin/dev
<span class="token comment"># &#x6B64;&#x65F6;&#x5C31;&#x53EF;&#x4EE5;&#x6109;&#x5FEB;&#x7684;&#x8FDB;&#x884C;&#x5F00;&#x53D1;&#x4E86;O(&#x2229;_&#x2229;)O~~</span>
</code></pre>
<p>&#x62C9;&#x53D6;&#x6307;&#x5B9A;&#x5206;&#x652F;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> clone -b BRANCH_NAME <span class="token operator">&lt;</span>REPO<span class="token operator">&gt;</span>
</code></pre>
<p>&#x5220;&#x9664;&#x8FDC;&#x7A0B;&#x5206;&#x652F;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> push origin --delete <span class="token punctuation">[</span>branchname<span class="token punctuation">]</span>
</code></pre>
<h1 id="git&#x6807;&#x7B7E;&#x7BA1;&#x7406;"><a name="git&#x6807;&#x7B7E;&#x7BA1;&#x7406;" class="anchor-navigation-ex-anchor" href="#git&#x6807;&#x7B7E;&#x7BA1;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>4. Git&#x6807;&#x7B7E;&#x7BA1;&#x7406;</h1>
<h2 id="&#x521B;&#x5EFA;&#x6807;&#x7B7E;"><a name="&#x521B;&#x5EFA;&#x6807;&#x7B7E;" class="anchor-navigation-ex-anchor" href="#&#x521B;&#x5EFA;&#x6807;&#x7B7E;"><i class="fa fa-link" aria-hidden="true"></i></a>4.1. &#x521B;&#x5EFA;&#x6807;&#x7B7E;</h2>
<ol>
<li>&#x9996;&#x5148;&#x5207;&#x6362;&#x5230;&#x8981;&#x6253;&#x6807;&#x7684;&#x5206;&#x652F;&#xFF0C;&#x7136;&#x540E;&#x4F7F;&#x7528;<code>tag</code>&#x5C31;&#x53EF;&#x4EE5;&#x6253;&#x4E00;&#x4E2A;&#x6807;&#x7B7E;</li>
</ol>
<pre class="language-"><code class="lang-bash">&#x279C;  test01 git:<span class="token punctuation">(</span>dev<span class="token punctuation">)</span> <span class="token function">git</span> checkout master 
Switched to branch <span class="token string">&apos;master&apos;</span>
Your branch is up to <span class="token function">date</span> with <span class="token string">&apos;origin/master&apos;</span><span class="token builtin class-name">.</span>

&#x279C;  test01 git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> tag v1.0
</code></pre>
<ol>
<li>&#x5982;&#x679C;&#x4F60;&#x60F3;&#x8981;&#x4E3A;&#x4EE5;&#x524D;&#x7684;&#x67D0;&#x4E2A;&#x65F6;&#x95F4;&#x70B9;&#x7684;&#x67D0;&#x4E2A;&#x63D0;&#x4EA4;&#x6253;&#x6807;&#x7B7E;&#x7684;&#x8BDD;&#xFF0C;&#x53EA;&#x9700;&#x8BB0;&#x4F4F;&#x8981;&#x6253;&#x6807;&#x7684;<code>commit id</code>&#x5373;&#x53EF;</li>
</ol>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> tag v0.9 f37704406a57769df47ef8f4128ced31b89726bb            <span class="token comment"># &#x957F;&#x77ED;&#x63D0;&#x4EA4;id&#x90FD;&#x53EF;&#x4EE5;</span>
</code></pre>
<ol>
<li>&#x4F7F;&#x7528;<code>git tag</code>&#x6765;&#x67E5;&#x770B;&#x6240;&#x6709;&#x6807;&#x7B7E;&#xFF0C;&#x9ED8;&#x8BA4;&#x7684;&#x6807;&#x7B7E;&#x662F;&#x5728;&#x6700;&#x65B0;&#x7684;commit&#x57FA;&#x7840;&#x4E0A;&#x8FDB;&#x884C;&#x7684;</li>
</ol>
<p><strong>&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x4E00;&#x70B9;&#x662F;</strong>&#xFF1A;&#x6807;&#x7B7E;&#x7684;&#x5148;&#x540E;&#x987A;&#x5E8F;&#x4E0D;&#x662F;&#x4EE5;&#x65F6;&#x95F4;&#x6392;&#x5E8F;&#x7684;&#xFF0C;&#x800C;&#x662F;&#x6309;&#x7167;&#x5B57;&#x6BCD;&#x6392;&#x5E8F;&#x7684;.</p>
<ol>
<li>&#x4F7F;&#x7528;<code>git show <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>TAG_NAME</span><span class="token punctuation">&gt;</span></span></code>&#x6765;&#x67E5;&#x770B;&#x6807;&#x7B7E;&#x7684;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;</li>
</ol>
<pre class="language-"><code class="lang-bash">&#x279C;  test01 git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> show v1.0 
commit f65818b4a8a4f665b2ac9c9598be06971c04f129 <span class="token punctuation">(</span>HEAD -<span class="token operator">&gt;</span> master, tag: v1.0, origin/master, origin/HEAD<span class="token punctuation">)</span>
Author: AGou-ops <span class="token operator">&lt;</span>suofeiyaxx@gmail.com<span class="token operator">&gt;</span>
Date:   Mon Dec <span class="token number">9</span> 09:34:10 <span class="token number">2019</span> +0800

    <span class="token function">add</span> <span class="token number">222</span> <span class="token keyword">for</span> commit_record

    <span class="token function">add</span> <span class="token number">333</span> <span class="token keyword">for</span> commit_record

    <span class="token function">add</span> <span class="token number">111</span> <span class="token keyword">for</span> commit_record

<span class="token function">diff</span> --git a/commit_record b/commit_record
index 5f2f16b<span class="token punctuation">..</span>06539be <span class="token number">100644</span>
--- a/commit_record
+++ b/commit_record
@@ -1 +1,6 @@
 <span class="token number">1111</span>
+<span class="token operator">&lt;&lt;&lt;</span><span class="token operator">&lt;&lt;&lt;</span><span class="token operator">&lt;</span> HEAD
+2222
+3333
<span class="token operator">+=</span><span class="token operator">==</span><span class="token operator">==</span><span class="token operator">==</span>
+<span class="token operator">&gt;&gt;</span><span class="token operator">&gt;&gt;</span><span class="token operator">&gt;&gt;</span><span class="token operator">&gt;</span> 0ad1d42<span class="token punctuation">..</span>. <span class="token function">add</span> <span class="token number">111</span> <span class="token keyword">for</span> commit_record
</code></pre>
<ol>
<li>&#x6B64;&#x5916;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x5E26;&#x6709;&#x8BF4;&#x660E;&#x7684;&#x6807;&#x7B7E;&#xFF0C;&#x7528;<code>-a</code>&#x6307;&#x5B9A;&#x6807;&#x7B7E;&#x540D;&#xFF0C;<code>-m</code>&#x6307;&#x5B9A;&#x8BF4;&#x660E;&#x6587;&#x5B57;</li>
</ol>
<pre class="language-"><code class="lang-bash">&#x279C;  test01 git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> tag -a v0.91 -m <span class="token string">&quot;v0.91&quot;</span> 0bef827

&#x279C;  test01 git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> <span class="token function">git</span> show v0.91                                                                                                    <span class="token number">11</span>:13:09
tag v0.91
Tagger: AGou-ops <span class="token operator">&lt;</span>suofeiyaxx@gmail.com<span class="token operator">&gt;</span>
Date:   Mon Dec <span class="token number">9</span> <span class="token number">11</span>:13:06 <span class="token number">2019</span> +0800

v0.91            <span class="token comment"># &#x8FD9;&#x91CC;&#x5C31;&#x662F;&#x6253;&#x6807;&#x65F6;&#x7684;&#x4FE1;&#x606F;</span>

commit 0bef8272562bb96ba4b5a18196eb43773587f618 <span class="token punctuation">(</span>tag: v0.91<span class="token punctuation">)</span>
Author: AGou-ops <span class="token operator">&lt;</span>suofeiyaxx@gmail.com<span class="token operator">&gt;</span>
Date:   Sun Dec <span class="token number">8</span> <span class="token number">20</span>:39:06 <span class="token number">2019</span> +0800

    Add branch_dev

<span class="token function">diff</span> --git a/branch_dev b/branch_dev
new <span class="token function">file</span> mode <span class="token number">100644</span>
index 0000000<span class="token punctuation">..</span>0ad9642
--- /dev/null
+++ b/branch_dev
@@ -0,0 +1 @@
+some changes on dev branch.
</code></pre>
<h2 id="&#x5220;&#x9664;&#x672C;&#x5730;&#x6216;&#x8FDC;&#x7A0B;&#x6807;&#x7B7E;"><a name="&#x5220;&#x9664;&#x672C;&#x5730;&#x6216;&#x8FDC;&#x7A0B;&#x6807;&#x7B7E;" class="anchor-navigation-ex-anchor" href="#&#x5220;&#x9664;&#x672C;&#x5730;&#x6216;&#x8FDC;&#x7A0B;&#x6807;&#x7B7E;"><i class="fa fa-link" aria-hidden="true"></i></a>4.2. &#x5220;&#x9664;&#x672C;&#x5730;&#x6216;&#x8FDC;&#x7A0B;&#x6807;&#x7B7E;</h2>
<p>&#x5220;&#x9664;&#x672C;&#x5730;&#x6807;&#x7B7E;&#xFF1A;<code>git tag -d <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>TAG_NAME</span><span class="token punctuation">&gt;</span></span></code></p>
<p>&#x63A8;&#x9001;&#x672C;&#x5730;&#x6807;&#x7B7E;&#x5230;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#xFF1A;<code>git push origin <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>TAG_NAME</span><span class="token punctuation">&gt;</span></span></code></p>
<p>&#x4E00;&#x6B21;&#x6027;&#x63A8;&#x9001;&#x6240;&#x6709;&#x672C;&#x5730;&#x6807;&#x7B7E;&#x5230;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#xFF1A;<code>git push origin --tags</code></p>
<p>&#x5982;&#x679C;&#x6807;&#x7B7E;&#x5DF2;&#x7ECF;&#x63A8;&#x9001;&#x5230;&#x8FDC;&#x7A0B;&#xFF0C;&#x5148;&#x4ECE;&#x672C;&#x5730;&#x5220;&#x9664;&#xFF0C;&#x7136;&#x540E;&#x5728;&#x4ECE;&#x8FDC;&#x7A0B;&#x5220;&#x9664;&#xFF1A;<code>git push origin :refs/tags/<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>TAG_NAME</span><span class="token punctuation">&gt;</span></span></code></p>
<h1 id="gitignore&#x6587;&#x4EF6;"><a name="gitignore&#x6587;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#gitignore&#x6587;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>5. .gitignore&#x6587;&#x4EF6;</h1>
<blockquote>
<p>GitHub&#x5B98;&#x65B9;&#x63D0;&#x4F9B;&#x7684;&#x6709;&#x7528;&#x7684;.gitignore&#x6A21;&#x677F;&#x6587;&#x4EF6;&#xFF1A;<a href="https://github.com/github/gitignore" target="_blank">https://github.com/github/gitignore</a></p>
</blockquote>
<p><code>.gitignore</code>&#x7528;&#x4E8E;&#x5FFD;&#x7565;&#x7279;&#x6B8A;&#x6587;&#x4EF6;.</p>
<p>&#x5FFD;&#x7565;&#x6587;&#x4EF6;&#x7684;&#x539F;&#x5219;&#x662F;&#xFF1A;</p>
<ol>
<li>&#x5FFD;&#x7565;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x6BD4;&#x5982;&#x7F29;&#x7565;&#x56FE;&#x7B49;&#xFF1B;</li>
<li>&#x5FFD;&#x7565;&#x7F16;&#x8BD1;&#x751F;&#x6210;&#x7684;&#x4E2D;&#x95F4;&#x6587;&#x4EF6;&#x3001;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x7B49;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x662F;&#x901A;&#x8FC7;&#x53E6;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x7684;&#xFF0C;&#x90A3;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x7684;&#x6587;&#x4EF6;&#x5C31;&#x6CA1;&#x5FC5;&#x8981;&#x653E;&#x8FDB;&#x7248;&#x672C;&#x5E93;&#xFF0C;&#x6BD4;&#x5982;Java&#x7F16;&#x8BD1;&#x4EA7;&#x751F;&#x7684;<code>.class</code>&#x6587;&#x4EF6;&#xFF1B;</li>
<li>&#x5FFD;&#x7565;&#x4F60;&#x81EA;&#x5DF1;&#x7684;&#x5E26;&#x6709;&#x654F;&#x611F;&#x4FE1;&#x606F;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x6BD4;&#x5982;&#x5B58;&#x653E;&#x53E3;&#x4EE4;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x3002;</li>
</ol>
<p>&#x4F60;&#x60F3;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#xFF0C;&#x4F46;&#x662F;&#x63D0;&#x793A;<code>The following paths are ignored by one of your .gitignore files ...</code>&#xFF0C;&#x5982;&#x679C;&#x4F60;&#x786E;&#x5B9E;&#x60F3;&#x8981;&#x6DFB;&#x52A0;&#x8BE5;&#x6587;&#x4EF6;&#x5230;Git&#x4E2D;&#x53BB;&#xFF0C;&#x90A3;&#x4E48;&#x4F60;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>-f</code>&#x5F3A;&#x5236;&#x6DFB;&#x52A0;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">git</span> <span class="token function">add</span> -f test.class
</code></pre>
<p>&#x6216;&#x8005;&#x4F60;&#x53D1;&#x73B0;&#xFF0C;&#x53EF;&#x80FD;&#x662F;<code>.gitignore</code>&#x5199;&#x5F97;&#x6709;&#x95EE;&#x9898;&#xFF0C;&#x9700;&#x8981;&#x627E;&#x51FA;&#x6765;&#x5230;&#x5E95;&#x54EA;&#x4E2A;&#x89C4;&#x5219;&#x5199;&#x9519;&#x4E86;&#xFF0C;&#x53EF;&#x4EE5;&#x7528;<code>git check-ignore</code>&#x547D;&#x4EE4;&#x68C0;&#x67E5;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">&#x279C;  test01 git:<span class="token punctuation">(</span>master<span class="token punctuation">)</span> &#x2717; <span class="token function">git</span> check-ignore -v ignore.file
.gitignore:1:*.file     ignore.file
</code></pre>
<h1 id="git&#x5176;&#x4ED6;"><a name="git&#x5176;&#x4ED6;" class="anchor-navigation-ex-anchor" href="#git&#x5176;&#x4ED6;"><i class="fa fa-link" aria-hidden="true"></i></a>6. Git&#x5176;&#x4ED6;</h1>
<h3 id="git-pull-&#x64A4;&#x9500;&#x8BEF;&#x64CD;&#x4F5C;"><a name="git-pull-&#x64A4;&#x9500;&#x8BEF;&#x64CD;&#x4F5C;" class="anchor-navigation-ex-anchor" href="#git-pull-&#x64A4;&#x9500;&#x8BEF;&#x64CD;&#x4F5C;"><i class="fa fa-link" aria-hidden="true"></i></a>git pull &#x64A4;&#x9500;&#x8BEF;&#x64CD;&#x4F5C;</h3>
<p>&#x672C;&#x6765;&#x60F3;&#x628A;github&#x4E0A;&#x7684;newpbft&#x5408;&#x5E76;&#x5230;&#x672C;&#x5730;&#x7684;newpbft&#x5206;&#x652F;&#x4E0A;&#xFF0C;&#x7531;&#x4E8E;&#x6CA1;&#x6709;&#x67E5;&#x770B;&#x5F53;&#x524D;&#x5206;&#x652F;&#xFF0C;&#x76F4;&#x63A5;&#x8FD0;&#x7528;git pull origin newpbft&#xFF0C;&#x7ED3;&#x679C;&#x5C06;newpbft&#x5408;&#x5E76;&#x5230;&#x4E86;master&#x5206;&#x652F;&#x4E2D;&#x3002;
&#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#xFF1A;<br>1&#x3001;&#x8FD0;&#x884C;git reflog&#x547D;&#x4EE4;&#x67E5;&#x770B;&#x4F60;&#x7684;&#x5386;&#x53F2;&#x53D8;&#x66F4;&#x8BB0;&#x5F55;<br>2&#x3001;&#x7136;&#x540E;&#x7528;git reset --hard HEAD@{n}&#xFF0C;&#xFF08;n&#x662F;&#x4F60;&#x8981;&#x56DE;&#x9000;&#x5230;&#x7684;&#x5F15;&#x7528;&#x4F4D;&#x7F6E;&#xFF09;&#x56DE;&#x9000;&#x3002; </p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; AGou 2020 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2020-03-02 20:42:24
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev " aria-label="Previous page: Git">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="GitLab服务器.html" class="navigation navigation-next " aria-label="Next page: GitLab服务器">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Git基础","level":"1.10.1","depth":2,"next":{"title":"GitLab服务器","level":"1.10.2","depth":2,"path":"Git/GitLab服务器.md","ref":"Git/GitLab服务器.md","articles":[]},"previous":{"title":"Git","level":"1.10","depth":1,"path":"Git/README.md","ref":"Git/README.md","articles":[{"title":"Git基础","level":"1.10.1","depth":2,"path":"Git/Git基础.md","ref":"Git/Git基础.md","articles":[]},{"title":"GitLab服务器","level":"1.10.2","depth":2,"path":"Git/GitLab服务器.md","ref":"Git/GitLab服务器.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["github@^2.0.0","edit-link@^2.0.2","anchors@^0.7.1","include-codeblock@^3.0.2","tbfed-pagefooter@^0.0.1","expandable-chapters-small@^0.1.7","anchor-navigation-ex@0.1.8","prism","-highlight","insert-logo","-lunr","-search","search-pro","splitter","lightbox","github-buttons","-sharing","sharing-plus","donate","code","-klipse","livereload"],"root":".","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright © AGou 2020","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prismjs/themes/prism-tomorrow.css"]},"github":{"url":"https://github.com/AGou-ops"},"livereload":{},"splitter":{},"search-pro":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"code":{"copyButtons":true},"donate":{"alipay":"https://agou-ops.github.io/images/alipay.png","alipayText":"支付宝打赏","button":"打赏","title":"","wechat":"https://agou-ops.github.io/images/wechatpay.png","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"anchor-navigation-ex":{"isRewritePageTitle":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"},"lightbox":{"jquery":true,"sameUuid":false},"github-buttons":{"repo":"AGou-ops/myStudyNote","types":["star","watch","fork"],"size":"small"},"expandable-chapters-small":{},"include-codeblock":{"check":false,"edit":true,"fixlang":false,"lang":"","template":"ace","theme":"chrome","unindent":true},"sharing":{"qq":true,"all":["douban","facebook","google","hatenaBookmark","instapaper","linkedin","twitter","weibo","messenger","qq","qzone","viber","vk","weibo","pocket","stumbleupon","whatsapp"],"douban":false,"facebook":false,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":true,"linkedin":false},"edit-link":{"label":"Edit This Page","base":"https://github.com/AGou-ops/myStudyNote"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"anchors":{},"insert-logo":{"style":"background: none; max-height: 50px; min-height: 50px","url":"https://s2.ax1x.com/2019/12/10/QBD0xO.jpg"}},"theme":"default","author":"AGou","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"AGou's StudyNote","language":"zh-hans","output.name":"site","links":{"sidebar":{"◆点击进入我的个人博客":"http://agou-ops.github.io"}},"gitbook":"3.2.3","description":"岂能尽如人意，但求无愧我心。"},"file":{"path":"Git/Git基础.md","mtime":"2020-03-02T12:42:24.284Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-03-02T12:42:32.383Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lightbox/js/lightbox.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

